Shared parameter definitions: resolution groundwork (1/2)#31
Merged
Conversation
Add CLI-scoped (Cli.Parameters) and global (SnipStoreDocument.GlobalParameters) parameter definitions, resolved by name with precedence local > CLI > global via a new Core ParameterResolver. ParameterFillViewModel now fills from the resolved effective set rather than snip.Parameters directly, so a Snip can omit a parameter and inherit the shared definition; defining it locally overrides. Resolution is additive — effective set = local params plus any template token not defined locally that a CLI/global scope provides; tokens defined nowhere stay un-prompted (bare-token verbatim copy preserved). With empty shared collections, behaviour is identical to before. Store schema bumped to v2 (additive); JsonSnipStore stamps v2 on save so an older build refuses the store rather than silently dropping shared params. IShellInteractions.FillParametersAsync now takes the resolved parameters. Management UI (CLI editor + global, in the main UI) lands in part 2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Editing a CLI (rename or icon change) rebuilt a fresh Cli with only Id/Name/ IconRef, which dropped the new Parameters collection — a rename would wipe CLI-scoped shared parameters and the snips inheriting them. Carry Parameters through in CliEditorViewModel.BuildUpdatedCli and both ShellViewModel icon-save reconstructions. Found by codex review. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of the shared parameter definitions feature (task #1) — the Core resolution groundwork. Management UI is part 2.
Design confirmed with you: name-based precedence (Snip-local → CLI → global), no reference objects/IDs; Core-first staging.
What this PR does
Cli.Parameters(CLI-scoped) andSnipStoreDocument.GlobalParameters(global), bothList<Parameter>defaulting to[].ParameterResolver(Core/Engine): computes a Snip's effective parameter set — local params, plus any template token not defined locally that a CLI/global scope provides (CLI wins over global). Tokens defined in no scope are left out, so the "bare token copies verbatim" behaviour (the feat/phase-6-settings: editable settings + Velopack updater (stacked on #8) #9-era fix) is preserved. Additive: with empty shared collections, behaviour is byte-for-byte the same as before.ParameterFillViewModelnow fills from the resolved set;ShellViewModel.CopySnipAsyncresolves it (and uses it for the skip-the-flyout check, so an inherited param correctly opens the flyout).IShellInteractions.FillParametersAsynctakes the resolved parameters.JsonSnipStorestamps v2 on every save, so an older v1-only build refuses the store rather than silently dropping shared definitions. Source-gen already coversParameter, so no new[JsonSerializable]needed; byte-identical compatibility tests still pass.Not in this PR (part 2)
The UI to manage shared parameters: CLI-scoped in the CLI editor dialog, and global params in the main UI (not Settings, per your call). Until then, shared params resolve correctly but can only be added by hand-editing the store — so this PR has no user-visible behaviour change on its own.
Tests
ParameterResolverTests(8): local-only, CLI inherit, local-overrides-CLI, CLI-over-global, global fallback, undefined-token-omitted, local-not-in-template retained, ordering.ParameterFillViewModeltests + the fake interaction for the new signature.🤖 Generated with Claude Code